package com.book.DUtils;

import lombok.Data;

@Data
public class Res {
    private int code;
    private String msg;
    private Long total;//总记录数
    private Object data;//数据

    public static Res fail(){
        return res(400,"失败",0L,null);
    }

    public static Res sucess(){
        return res(200,"成功",0L,null);
    }

    public static Res sucess(Object data){
        return res(200,"成功",0L,data);
    }

    public static Res sucess(Object data,Long total){
        return res(200,"成功",total,data);
    }

    private static Res res(int code,String msg,Long total,Object data){
        Res res = new Res();
        res.setCode(code);
        res.setMsg(msg);
        res.setData(data);
        res.setTotal(total);
        return res;
    }

}
